package com.x.chalk.controller;


import com.x.chalk.config.SystemConfig;
import com.x.chalk.dto.SignTaskDto;
import com.x.chalk.service.intf.SignTaskService;
import com.x.chalk.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@CrossOrigin
@RequestMapping("/api/signTask/")
@Api(tags = "签到任务相关操作")
public class SignTaskController {

    @Autowired
    private SignTaskService service;

    @GetMapping("getScore.do")
    @ApiOperation(value = "添加积分")
    public R getScore(Long id, HttpServletRequest request){
        return service.getScore(id,request.getHeader(SystemConfig.HEADER_TOKEN));
    }

    @PostMapping("updateFlag.do")
    @ApiOperation(value = "修改任务状态")
    public R updateFlag(SignTaskDto dto, HttpServletRequest request){
        return service.updateFlag(dto,request.getHeader(SystemConfig.HEADER_TOKEN));
    }

    @GetMapping("queryFlag.do")
    @ApiOperation(value = "查询任务状态")
    public R queryFlag(HttpServletRequest request,Long taskid){
        return service.queryFlag(request.getHeader(SystemConfig.HEADER_TOKEN),taskid);
    }
}
